
package com.scalar.forecast.salesPersonSetup.actions;

import com.scalar.forecast.ForecastExtendedAction;
import com.scalar.forecast.salesPersonSetup.actionCommands.SalesPersonSetupActionCommandFactory;
import com.scalar.forecast.actionCommands.ActionCommand;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/** Action class to handle the requests from sales person setup screen.
 *
 * Created by Gandhi.
 * Date: Feb 8, 2005
 * Time: 5:30:42 PM
 */

public class SalesPersonSetupAction extends ForecastExtendedAction{



    public ActionForward executeRequest( ActionMapping mapping,
                                         ActionForm form,
                                         HttpServletRequest request,
                                         HttpServletResponse response ) throws Exception
    {

        ActionForward actionForward =  mapping.findForward("salesPersonSetup");
        String action = request.getParameter("action");

        try {

                if ( action == null ) {
                    action = ACTION_NEW;
                }
                if( "Level".equalsIgnoreCase( action ) == true ) {
                    action = ACTION_LOAD_LEVEL;
                }
                if( "SalesPerson".equalsIgnoreCase( action ) == true ) {
                    action = ACTION_LOAD_SALES;
                }
                if( "Save".equalsIgnoreCase( action ) == true ) {
                    action = ACTION_SAVE;
                }
                ActionCommand actionCommand = SalesPersonSetupActionCommandFactory.getActionCommand( action );
                actionForward = actionCommand.execute( mapping, form, request, response );

            }
            catch( Exception e)
            {
                e.printStackTrace();
            }

        return actionForward ;
    }

}
